# -*- coding: utf-8 -*-
from __future__ import print_function
import gnn_methods as gm
import sys
trainning_task_file         = 'train_task.cfg'
trainning_input_file        = './train_input/'
model_path                  = './saved_model/'
summary_path                = './network/'
first_trainning             = 0
hit_arg = 0;
totalLen = len(sys.argv)
for it in range(totalLen):
    if sys.argv[it].startswith('-t') :
        if it < totalLen - 1:
            trainning_task_file = sys.argv[it+1]
            print('task_file :',trainning_task_file)
            hit_arg = hit_arg + 1
    if sys.argv[it].startswith('-i') :
        if it < totalLen - 1:
            trainning_input_file = sys.argv[it+1]
            print('input_path :',trainning_input_file)
            hit_arg = hit_arg + 1
    if sys.argv[it].startswith('-m') :
        if it < totalLen - 1:
            model_path = sys.argv[it+1]
            print('model_path :',model_path)
            hit_arg = hit_arg + 1
    if sys.argv[it].startswith('-s') :
        if it < totalLen - 1:
            summary_path = sys.argv[it+1]
            print('summary_path :',summary_path)
    if sys.argv[it].startswith('-f') :
        first_trainning = 1
        print('first_trainning : true')
    if sys.argv[it].startswith('-h') :
            hit_arg = -3

if hit_arg < 3:
    print ("""
           训练神经网络
           python cmd_first_trainning.py 
               -t \\path\\to\\任务配置.cfg
               -i \\path\\to\\训练样本文件夹
               -m \\path\\to\\结果文件夹
               -s \\path\\to\\日志文件夹
               -f 存在时，会执行首次训练前初始化。只在首次训练时提交-f    
           """       
    )
    
sys.stdout.flush()
result = gm.train_model(trainning_task_file,trainning_input_file,model_path,first_trainning,summary_path)
sys.stdout.flush()        
#mp.plot(result["x_plot"],result["y_plot"],'b')
